package com._520it.crm.web.controller;

import com._520it.crm.domain.CarModel;
import com._520it.crm.service.ICarModelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/carModel")
public class CarModelControlller {
    @Autowired
    private ICarModelService carModelService;

    @RequestMapping("/selectParent")
    @ResponseBody
    public List<CarModel> selectParent(){
        List<CarModel> carModelList = carModelService.selectParent();
        return carModelList;
    }
    @RequestMapping("/selectChildByParentId")
    @ResponseBody
    public List<CarModel> selectChildByParentId(Long parentId){
        List<CarModel> carModelList = null;
        if(parentId != null) {
            carModelList = carModelService.selectChildByParentId(parentId);
        }
        return carModelList;
    }
}
